<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			<cpm :list='list'></cpm>
			
			<cpm :list='list'>
				<!-- 注意：slot-scope是放在template里面 -->
				<template slot-scope='list1'>
					<ol>
						<li v-for="item in list1.data">
							{{item.name}}
						</li>
					</ol>
				</template>
			</cpm>
			
			<cpm :list='list'></cpm>
		</div>
		<script src="../vue.js"></script>
		<script type="text/javascript">
			Vue.component('cpm', {
				props: {
					'list': {
						type: Array,
						required: true,
						default: () => []
					}
				},
				template: `
				  <div>
						<slot :data='list'>
							<ul>
								<li :key='item.id' v-for='item in list'>
									{{item.name}}
								</li>
							</ul>
						</slot>
					</div>
				`
			})
			var vm = new Vue({
				el: "#app",
				data: {
					list: [
						{
							id: 1,
							name: '苹果'
						},
						{
							id: 2,
							name: '香蕉'
						},
						{
							id: 3,
							name: '西瓜'
						},
						{
							id: 4,
							name: '橙子'
						}
					]
				},
				methods: {}
			})
		</script>
	</body>
</html>

